﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="adm_assign_user_cat.aspx.cs" Inherits="adm_assignusercat" Title="Untitled Page" %>
<%@ Register src="UserControls/AdminMenuLeft.ascx" tagname="AdminMenuLeft" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">

    <script type='text/javascript'>
        function SelectAllCheckBox()
        {
            var arrChk= document.getElementById('selectAllCheckBox').getElementsByTagName("input");
          
            for(var i=0;i<arrChk.length;i++)
            {
                if(arrChk[i].id.indexOf("chckRole")>0)
                {								                 
                    arrChk[i].checked=true;
                }
            }								        
        }
        function DeselectAllCheckBox()
        {
            var arrChk= document.getElementById('selectAllCheckBox').getElementsByTagName("input");
            for(var i=0;i<arrChk.length;i++)
            {
                if(arrChk[i].id.indexOf("chckRole")>0)
                {
                    arrChk[i].checked=false;
                }
            }	
        }
        
        function SelectAllCheckBox2()
        {
            var arrChk= document.getElementById('selectAllCheckBox2').getElementsByTagName("input");
          
            for(var i=0;i<arrChk.length;i++)
            {
                if(arrChk[i].id.indexOf("chkName")>0)
                {								                 
                    arrChk[i].checked=true;
                }
            }								        
        }
        function DeselectAllCheckBox2()
        {
            var arrChk= document.getElementById('selectAllCheckBox2').getElementsByTagName("input");
            for(var i=0;i<arrChk.length;i++)
            {
                if(arrChk[i].id.indexOf("chkName")>0)
                {
                    arrChk[i].checked=false;
                }
            }	
        }
    </script>
	<div class="adm-wrap">
		<h3>Assign User To Category</h3>
		<div class="article" style="border:0px">
			<p class="hi"><asp:Label ID="lblGretting" Text="Hi admin Khuong luu" runat="server"></asp:Label></p>
			<p class="hi"><asp:Label ID="lblAlert" runat="server" style="border:solid 1px Gray;padding:3px" Text="aaaaaaaaa" Visible="false"></asp:Label></p>
            <table width="100%" border="0px" cellspacing="0" style="border:none;" cellpadding="0">
                <tr>
                    <td colspan="2">
                        <div id="selectAllCheckBox2">
					        <table width="400px" cellspacing="0" cellpadding="0" border="0" style="border:1px solid #6b5a60">
						    <tbody>
							<tr>
							    <td colspan="2">
							        <table width="100%">
							            <tr>
							                <td>
								    <input type="button" onclick="SelectAllCheckBox2()"  class="submitbutton" value="Check All"/><input type="button" onclick="DeselectAllCheckBox2()" class="submitbutton" value="Uncheck All"/>
								</td>
								<td align="right">
								    <asp:DropDownList ID="drpSelectUserroles" runat="server" CssClass="medium_ex" 
                                        Width="150px" DataTextField="Name" DataValueField="UserTypeID">
									    <asp:ListItem Text="Select one" Value="0"></asp:ListItem>
									    <asp:ListItem Text="Approver" Value="0"></asp:ListItem>
									    <asp:ListItem Text="Editor" Value="0"></asp:ListItem>
                                    </asp:DropDownList>
								   <asp:Button ID="btnListUserGo" Cssclass="submitbutton" Text="Go" runat="server" 
                                        onclick="btnListUserGo_Click"/></td>
							            </tr>
							        </table>
							    </td>
								
							</tr>
							<tr class="listing">
							    <td class="ls"></td>
								<td class="ls">Full Name</td>
							</tr>
							<asp:Repeater ID="rptFullName" runat="server">
					            <ItemTemplate>
					                <tr>
					                    <td style="width:10%"><asp:CheckBox ID="chkName" runat="server" /></td>
					                    <td style=""><%# Eval("Lastname") %>&nbsp;<%# Eval("Firstname") %></td>
					                    <asp:Label ID="lblUID" runat="server" Visible="false" Text='<%# Eval("UserID") %>'></asp:Label>
					                </tr>
					            </ItemTemplate>
                            </asp:Repeater>
							<tr>
								<td colspan="2" class="ls">
								    Choose category bellow to assign user</td>
							</tr>
							<tr>
								<td colspan="2">
							    <table width="100%" cellspacing="0" cellpadding="3" border="0" style="border:none;">
								    <tbody>
									    <tr>
										    <td class="clstitle">&nbsp; Cat Type</td>
										    <td>
										        <asp:DropDownList ID="drpChooseType" runat="server" Cssclass="medium_ex" 
                                                    Width="150px" AutoPostBack="True" 
                                                    onselectedindexchanged="drpChooseType_SelectedIndexChanged">
                                                    <asp:ListItem Value="1">Main cat</asp:ListItem>
                                                    <asp:ListItem Value="2">Sub cat</asp:ListItem>
                                                </asp:DropDownList>
										    </td>
									    </tr>
									    <tr>
										    <td class="clsTitle">&nbsp; <asp:Label ID="lblMaincat" runat="server">Main Cat</asp:Label></td>
										    <td>
                                                <asp:DropDownList ID="drpMainCat" runat="server" Cssclass="medium_ex" 
                                                    Width="150px" AutoPostBack="True" 
                                                    onselectedindexchanged="drpMainCat_SelectedIndexChanged" 
                                                    DataTextField="UName" DataValueField="CatID">
                                                </asp:DropDownList>
										    </td>
									    </tr>
									    <tr>
										    <td class="clsTitle">&nbsp; <asp:Label ID="lblSubcat" runat="server">Sub Cat</asp:Label></td>
										    <td>
										        <asp:DropDownList ID="drpSubCat" runat="server" Cssclass="medium_ex" 
                                                    Width="150px" DataTextField="UName" DataValueField="SubCatID" >
                                                </asp:DropDownList>
                                            </td>
									    </tr>
									    <tr>
										    <td class="clsTitle" colspan="2" align="center">
										        <asp:Button CssClass="submitbutton" runat="server" ID="btnAddToCategory1" 
                                        Text="Add To Category" Width="140px" onclick="btnAddToCategory1_Click"/>
										        &nbsp;<asp:Button CssClass="submitbutton" runat="server" ID="btnViewRoles" 
                                        Text="View user of selected cat" Width="180px" onclick="btnViewRoles_Click"/>
                                            </td>
									    </tr>
									    </tbody>
								    </table>
								</td>
							</tr>
							<tr>
								<td colspan="2">
								</td>
							</tr>
						</tbody>
					    </table>
					    </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Panel ID="pnlUserRole" runat="server" Visible="false">
					        <table width="400px" cellspacing="0" cellpadding="0" border="0" style="border:1px solid #6b5a60">
					        <tbody>
					        <tr class="first">
						        <td colspan="2">Category</td>
					        </tr>
						    <tr>
							    <td colspan="2">
							    <div id="selectAllCheckBox">
							        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="border:none">
								        <tbody>
									        <tr style="padding-left: 5px;" class="listing">
									            <td class="ls"></td>
										        <td class="ls">Full Name</td>
										        <td class="ls">Permission</td>
										        <td class="ls">Category Name</td>
									        </tr>
									        <asp:Repeater ID="rptUserRoles" runat="server">
									            <ItemTemplate>
									                <tr>
									                    <td style="padding-left:3px"><asp:CheckBox ID="chckRole" runat="server" /></td>
									                    <td><%# GetUserName(int.Parse(Eval("UserId").ToString())) %></td>
									                    <td><%# GetUserType(int.Parse(Eval("UserId").ToString())) %></td>
									                    <td><%# GetCategoryname(int.Parse(Eval("CatID").ToString()),byte.Parse(Eval("CatLevel").ToString())) %></td>
									                    <asp:Label ID="lblUserID" Visible=false runat="server" Text='<%# Eval("UserID") %>'></asp:Label>
									                    <asp:Label ID="lblCatID" Visible=false runat="server" Text='<%# Eval("CatID") %>'></asp:Label>
									                </tr>
									            </ItemTemplate>
                                            </asp:Repeater>
								        </tbody>
								    </table>
								</div>
								</td>
						    </tr>
						    <tr>
							    <td colspan="2">
							        
							    </td>
						    </tr>
						    <tr>
							    <td>
							        <input class="submitbutton" onClick="SelectAllCheckBox()" type="button" 
                                        value="Check All" />
							        <input type="button" onClick="DeselectAllCheckBox()" class="submitbutton" 
                                        value="Uncheck All"/></td>
							    <td align="right">
							        <asp:Button Text="Remove From Category"  Cssclass="submitbutton" runat="server" 
                                        ID="btnRemoveFromCategory2" Width="150px" 
                                        onclick="btnRemoveFromCategory2_Click"/>
							    </td>
						    </tr>
					    </tbody>
					    </table>
					    </asp:Panel>
                    </td>
                </tr>
		    </table>
		</div>
	</div>
	<div class="clear"></div>
  <!--//Content-->
</asp:Content>

